
let room = require('./room')


class RoomMgr{
    //单例方法
    static getInstance() {
        if(!RoomMgr.instance){
            RoomMgr.instance = new RoomMgr();
            return RoomMgr.instance;
        }else{
            return RoomMgr.instance;
        }
    }
    constructor() {
        //存放 【房间】 的数组
        this._roomList = [];
    }

    //创建房间
    createRoom(type,roomData,client){
        let tmpRoom = new room(roomData,client);
        this._roomList.push(tmpRoom);
        global.PSZServerMgr.PSZMessageMgr.sendMessage(type,tmpRoom.getRoomInfo(),client);
        tmpRoom.addPlayer(roomData.create_id,client);
    }
}

module.exports = RoomMgr